<?php
class Admin_Model_Role extends TBB_Model_Role
{	
	/**
	 * Get role array except customer
	 * @return array
	 */
	public function getRoleArrayExceptCustomer()
	{		
		$roles = $this->getRoleArray();
		foreach($roles as $index => $role) {
			if($role['role_name'] == 'customer') {
				unset($roles[$index]);
				break;		
			}
		}
		return $roles;
	}
	
	/**
	 * Get role IDs from roleID-checked map
	 * @param array $roleMap This map has form Array([1] => 1, [2] => 0, [3] => 1, ..., [n] => m) with n is role ID and m is checked/unchecked
	 */
	public function getRoleIDsFromRoleIDIsCheckedMap($roleMap)
	{		
		$roleIDs = array();
		foreach($roleMap as $key => $value) {
			if($value == 1) {
				$roleIDs[] = $key;
			}
		}
		return $roleIDs;
	}
	
	
	
	
	//////////////// (deprecated) //////////////////
	/**
	 * Get role name from role ID
	 * @param int $roleID
	 * @return string
	 */
	private function getRoleNameFromRoleID($roleID)
	{
		$select = $this->select()->where('role_id = ?', $roleID);
		$r = $this->fetchRow($select);
		return empty($r) ? null : $r['role_name']; 
	}
}